package org.jtb.quickr;

import java.util.Properties;

/**
 * Base class for all quickr services.
 * <p>
 * All service methods in all service subclasses communicate errors
 * by throwing FlickrResponseException, a subclass of QuickrException.
 * FlickrResponsException has fields to indicate the error status,
 * code, and message.
 */
public abstract class Service {
    /**
     * Contains the quickr API properties. This properties object <i>must</i> include the following keys:
     * <p>
     * <ul>
     *    <li>serviceUrl
     *    <li>authUrl
     *    <li>staticUrl
     *    <li>apiKey
     *    <li>secret
     * </ul>
     */
    protected QuickrProperties properties;
    
    /**
     * Construct a new quick service with the default set of quickr API properties.
     * The properties are read from the file quickr.properties located in the class path.
     * @throws QuickrException If a problem occurs constructing the service.
     */
    public Service() throws QuickrException {
        properties = QuickrProperties.getDefaultInstance();
    }
    
    /**
     * Construct a new quickr service, with a non-default set of quickr API properties.
     * @param p The set of quickr API properties.
     * @throws QuickrException If a problem occurs constructing the service.
     */
    public Service(Properties p) throws QuickrException {
        properties = new QuickrProperties(p);
    }    
}   
    
 
